package com.loan.controller.system;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ObjectUtil;
import com.loan.common.core.controller.BaseController;
import com.loan.common.core.domain.PageQuery;
import com.loan.common.core.domain.Result;
import com.loan.common.core.page.TableDataInfo;
import com.loan.system.domain.UserEntity;
import com.loan.system.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author shiguang on 2022/8/29 11:06
 */
@Validated
@Api(value = "APP用户信息", tags = {"APP用户信息"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/user")
public class UserController extends BaseController {

    private final UserService userService;

    /**
     * 获取用户详情
     */
    @ApiOperation("获取用户详情")
    //@SaCheckPermissio("app:user:query")
    @GetMapping(value = {"/", "/{id}"})
    public Result<UserEntity> getInfo(@ApiParam("用户ID") @PathVariable(value = "id", required = false) Long id) {
        if (ObjectUtil.isNotNull(id)) {
            return Result.ok(userService.selectUserById(id));
        }
        return Result.ok();
    }
}
